


>  Makefile            |   7 ++-
>  README              |   2 +-
>  configure.c         |  33 ++++++++++-
>  defs.h              | 136 +++++++++++++++++++++++++++++++++++++++++++-
>  diskdump.c          |  24 +++++++-
>  help.c              |   2 +-
>  lkcd_vmdump_v2_v3.h |   2 +-
>  netdump.c           |  11 +++-
>  ramdump.c           |   2 +
>  riscv64.c           |  45 +++++++++++++++
>  symbols.c           |  10 ++++


 make target=riscv64

noasan/lrealpath.o

.deps/libz_a-compress.Tpo
test -f 'inffast.c' || echo 




#define IS_VMALLOC_ADDR(X) (vt->vmalloc_start && (ulong)(X) >= vt->vmalloc_start)

#define MODULES_VADDR           (machdep->machspec->modules_vaddr)
#define MODULES_END             (machdep->machspec->modules_end)
#define VMALLOC_START           (machdep->machspec->vmalloc_start_addr)
#define VMALLOC_END             (machdep->machspec->vmalloc_end)

/* from arch/riscv/include/asm/pgtable.h */
#define __SWP_TYPE_SHIFT        6
#define __SWP_TYPE_BITS         5
#define __SWP_TYPE_MASK         ((1UL << __SWP_TYPE_BITS) - 1)
#define __SWP_OFFSET_SHIFT      (__SWP_TYPE_BITS + __SWP_TYPE_SHIFT)



#define MAX_SWAPFILES_CHECK()   \
               BUILD_BUG_ON(MAX_SWAPFILES_SHIFT __SWP_TYPE_BITS)

#define SWP_TYPE(entry)   (((entry) >__SWP_TYPE_SHIFT) & __SWP_TYPE_MASK)
#define SWP_OFFSET(entry) ((entry) >__SWP_OFFSET_SHIFT)
#define __swp_type(entry)       SWP_TYPE(entry)
#define __swp_offset(entry)     SWP_OFFSET(entry)



#define TIF_SIGPENDING          (THIS_KERNEL_VERSION >= LINUX(2,6,23) ? 1 : 2)
#define TIF_SIGPENDING         2


/* from arch/riscv/include/asm/sparsemem.h */
#define _SECTION_SIZE_BITS      27
#define _MAX_PHYSMEM_BITS       56


#endif  /* RISCV64 */



#ifdef RISCV64
#define MAX_HEXADDR_STRLEN (16)
#define UVADDR_PRLEN       (16)
#endif




> @@ -5112,6 +5159,9 @@ void dump_build_data(void);
>  #ifdef MIPS64
>  #define machdep_init(X) mips64_init(X)
>  #endif
#ifdef RISCV64
#define machdep_init(X) riscv64_init(X)
#endif
>  #ifdef SPARC64
>  #define machdep_init(X) sparc64_init(X)
>  #endif
> @@ -5592,6 +5642,9 @@ void display_help_screen(char *);
>  #ifdef SPARC64
>  #define dump_machdep_table(X) sparc64_dump_machdep_table(X)
>  #endif
#ifdef RISCV64
#define dump_machdep_table(X) riscv64_dump_machdep_table(X)
#endif
>  extern char *help_pointer[];
>  extern char *help_alias[];
>  extern char *help_ascii[];
> @@ -6653,6 +6706,87 @@ struct machine_specific {
>
>  #endif /* MIPS64 */



/*
 * riscv64.c
 */
void riscv64_display_regs_from_elf_notes(int, FILE *);

#ifdef RISCV64
void riscv64_init(int);
void riscv64_dump_machdep_table(ulong);

#define display_idt_table() \
	error(FATAL, "-d option is not applicable to RISCV64 architecture\n")

/* from arch/riscv/include/asm/ptrace.h */
struct riscv64_register {
	ulong regs[35];
};

struct riscv64_pt_regs {
	ulong badvaddr;
	ulong cause;
	ulong epc;
};

struct riscv64_unwind_frame {
	unsigned long pc;
	unsigned long ra;
	unsigned long sp;
};

#define KSYMS_START	(0x1)

struct machine_specific {
	ulong phys_base;
	ulong vmalloc_start_addr;
	ulong modules_vaddr;
	ulong modules_end;

	ulong _page_present;
	ulong _page_read;
	ulong _page_write;
	ulong _page_exec;
	ulong _page_user;
	ulong _page_global;
	ulong _page_accessed;
	ulong _page_dirty;
	ulong _page_soft;
	ulong _page_sec;
	ulong _page_share;
	ulong _page_buf;
	ulong _page_cache;
	ulong _page_so;
	ulong _page_special;
	ulong _page_table;
	ulong _page_prot_none;

	ulong _pfn_shift;

	struct riscv64_register *crash_task_regs;
};
/* from arch/riscv/include/asm/pgtable-bits.h */
#define 	_PAGE_PRESENT	(machdep->machspec->_page_present)
#define 	_PAGE_READ	(machdep->machspec->_page_read)
#define 	_PAGE_WRITE	(machdep->machspec->_page_write)
#define 	_PAGE_EXEC	(machdep->machspec->_page_exec)
#define 	_PAGE_USER	(machdep->machspec->_page_user)
#define 	_PAGE_GLOBAL	(machdep->machspec->_page_global)
#define 	_PAGE_ACCESSED	(machdep->machspec->_page_accessed)
#define 	_PAGE_DIRTY	(machdep->machspec->_page_dirty)
#define 	_PAGE_SOFT	(machdep->machspec->_page_soft)
#define 	_PAGE_SEC	(machdep->machspec->_page_sec)
#define 	_PAGE_SHARE	(machdep->machspec->_page_share)
#define 	_PAGE_BUF	(machdep->machspec->_page_buf)
#define 	_PAGE_CACHE	(machdep->machspec->_page_cache)
#define 	_PAGE_SO	(machdep->machspec->_page_so)
#define 	_PAGE_SPECIAL	_PAGE_SOFT
#define		_PAGE_TABLE	_PAGE_PRESENT
#define 	_PAGE_PROT_NONE	_PAGE_READ
#define 	_PAGE_PFN_SHIFT	10

#endif /* RISCV64 */





else if (STRNEQ(header->utsname.machine, "riscv64") &&
           machine_type_mismatch(file, "RISCV64", NULL, 0))
               goto err;

else if (machine_type("RISCV64"))
        dd->machine_type = EM_RISCV;


static void
get_diskdump_regs_riscv64(struct bt_info *bt, ulong *eip, ulong *esp)
{
       machdep->get_stack_frame(bt, eip, esp);
}

case EM_RISCV:
        get_diskdump_regs_riscv64(bt, eip, esp);
        break;


machine_type("SPARC64") || machine_type("MIPS64") ||
machine_type("RISCV64")) {


if (machine_type("RISCV64"))
               riscv64_display_regs_from_elf_notes(cpu, ofp);


machine_type("RISCV64"))




diff --git a/help.c b/help.c
diff --git a/lkcd_vmdump_v2_v3.h b/lkcd_vmdump_v2_v3.h
|| defined(RISCV64)

diff --git a/netdump.c b/netdump.c



case EM_RISCV:
        if (machine_type_mismatch(file, "RISCV64", NULL,
        source_query))
 		goto bailout;
 		break;


       } else if (machine_type("RISCV64")) {
               riscv64_display_regs_from_elf_notes(cpu, ofp);

 machine_type("RISCV64")

 diff --git a/ramdump.c b/ramdump.c

       else if (machine_type("RISCV64"))
               e_machine = EM_RISCV;

 diff --git a/riscv64.c b/riscv64.c



/* riscv64.c - core analysis suite
 *
 * Copyright (C) 2022 Alibaba Group Holding Limited.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifdef RISCV64

#include <elf.h>
#include "defs.h"

void
riscv64_dump_machdep_table(ulong arg)
{
}

void
riscv64_init(int when)
{
}

void
riscv64_display_regs_from_elf_notes(int cpu, FILE *ofp)
{
}

#else /* !RISCV64 */

#include "defs.h"

void
riscv64_display_regs_from_elf_notes(int cpu, FILE *ofp)
{
       return;
}

#endif /* !RISCV64 */


diff --git a/symbols.c b/symbols.c


              case EM_RISCV:
                      if (machine_type_mismatch(file, "RISCV64", NULL, 0))
                              goto bailout;
                      break;


              case EM_RISCV:
                      if (machine_type("RISCV64"))
                              return TRUE;
                      break;



https://www.spinics.net/linux/fedora/redhat-crash-utility/msg09696.html

(3)gcc的详细过程

详细过程可以分为四步：可以手动进行这四个步骤：
第一步：预处理。#号开头的代码全被解决掉(预编译，包含库，宏定义等等)，产生一个后缀.i的文件以便下一步使用。
gcc -E hello.c    (不会产生.i文件，文件内内容打印在了终端，所以需要将这些信息重定向到.i文件)
gcc -E hello.c >> hello.i

第二步：编译。这一步主要检查语法错误。产生一个后缀.s的文件(汇编文件)
gcc -S hello.i     (大写字母S)

第三步：汇编。产生后缀.o的object目标文件，二进制，但不可以运行，因为缺少库信息
gcc -c hello.s

第四步：链接。添加库信息，产生一个后缀.o的可执行文件
gcc hello.o -o hello

gcc -c 1.c进行编译生成1.o文件，然后通过objdump -h 1.o可以查看该目标文件的信息：


cc -o a ia64.c -g


objdump
Usage: objdump <option(s)> <file(s)>
 Display information from object <file(s)>.
 At least one of the following switches must be given:
  -a, --archive-headers    Display archive header information
  -f, --file-headers       Display the contents of the overall file header
  -p, --private-headers    Display object format specific file header contents
  -P, --private=OPT,OPT... Display object format specific contents
  -h, --[section-]headers  Display the contents of the section headers
  -x, --all-headers        Display the contents of all headers
  -d, --disassemble        Display assembler contents of executable sections
  -D, --disassemble-all    Display assembler contents of all sections
      --disassemble=<sym>  Display assembler contents from <sym>
  -S, --source             Intermix source code with disassembly
      --source-comment[=<txt>] Prefix lines of source code with <txt>
  -s, --full-contents      Display the full contents of all sections requested
  -g, --debugging          Display debug information in object file
  -e, --debugging-tags     Display debug information using ctags style
  -G, --stabs              Display (in raw form) any STABS info in the file
  -W[lLiaprmfFsoRtUuTgAckK] or
  --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
          =frames-interp,=str,=loc,=Ranges,=pubtypes,
          =gdb_index,=trace_info,=trace_abbrev,=trace_aranges,
          =addr,=cu_index,=links,=follow-links]
                           Display DWARF info in the file
  --ctf=SECTION            Display CTF info from SECTION
  -t, --syms               Display the contents of the symbol table(s)
  -T, --dynamic-syms       Display the contents of the dynamic symbol table
  -r, --reloc              Display the relocation entries in the file
  -R, --dynamic-reloc      Display the dynamic relocation entries in the file
  @<file>                  Read options from <file>
  -v, --version            Display this program's version number
  -i, --info               List object formats and architectures supported
  -H, --help               Display this information



  https://chromium.googlesource.com/native_client/nacl-gdb/+/449f92c6307d0d798b1dfe97b583ad79a8bacb19/gdb
  https://agentzh.org/misc/code/gdb/
  https://github.com/oracle/libdtrace-ctf/blob/master/libctf/ctf-open.c
  